package cn.tansanqinger.dao.sql.knowledge;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.tansanqinger.dao.sql.IKnowledgeSqlDao;
import cn.tansanqinger.dao.sql.IQueryKnowledgeSqlDao;
import cn.tansanqinger.pojo.Knowledge;
import cn.tansanqinger.pojo.Queryknowledge;

@Repository
public class KnowledgeSqlDaoImpl {

	@Autowired
	private IKnowledgeSqlDao dao;
	@Autowired
	private IQueryKnowledgeSqlDao qdao;
	
	/**
	 * 通过id查询数据
	 * @param id
	 * @return
	 */
	public Knowledge selectOne(int id) {
		return dao.selectById(id);
	}
	
	/**
	 * 查询数据
	 * @param uid
	 * @param id
	 * @return
	 */
	public Queryknowledge selectQidOne(int uid, int id) {
		QueryWrapper<Queryknowledge> queryWrapper = new QueryWrapper<Queryknowledge>();
		queryWrapper.lambda().eq(Queryknowledge::getUid, uid).eq(Queryknowledge::getKid, id).eq(Queryknowledge::getQisdispose, 0);
		return qdao.selectOne(queryWrapper);
	}
	
	/**
	 * 添加有疑问的数据信息
	 * @param object
	 * @return
	 */
	public int addQuery(Queryknowledge object) {
		return qdao.insert(object);
	}
	
	/**
	 * 修改有疑问的数据
	 * @param object
	 * @return
	 */
	public int modificationQuery(Queryknowledge object) {
		return qdao.updateById(object);
	}
	
	/**
	 * 修改数据
	 * @param object
	 * @return
	 */
	public int modificationKnowledge(Knowledge object) {
		return dao.updateById(object);
	}
	
}
